package cn.dcw.pethome.order.controller;


import cn.dcw.pethome.basic.util.AjaxResult;
import cn.dcw.pethome.basic.util.LoginContext;
import cn.dcw.pethome.order.service.IAdoptOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/adopt")
public class AdoptOrderController {

    @Autowired
    private IAdoptOrderService adoptOrderService;

    //宠物订单提交
    @PostMapping("/petOrder/submit")
    public AjaxResult submit(@RequestBody Map<String,Object> params, HttpServletRequest request){

        try{
            String payData = adoptOrderService.submit(params, LoginContext.getLoginInfo(request));
            System.out.println(payData);
            return new AjaxResult(true,"下单成功");
        }catch (Exception e){
            e.printStackTrace();
            return new AjaxResult(false, "操作失败");
        }

    }
}
